<?php
/**
 * Display Contact Document List
 *
 * @package Contact
 */
use Fox\Generator;
use Fox\Grid\FieldCat\Field\Renderer\Anchor;
$id = $params['id'];
$blkcv = new Fox\Html\Block('bDocs','Documents');
$blkcv->collapsed(false);
$grid = new Fox\Grid('documents',Generator::url('ressource','documents',null,array('rid' => $id)));
$grid->fieldcat(array('filename','doctype','uname','udate','export','idele'));
$grid->fieldcat()->switchToObjectMode();
$grid->fieldcat()->field('udate')->displayTime();

$grid->fieldcat()->field('filename')
	->openAsNewPage(true)
	->renderers(new Anchor(Generator::url('core','files','download',
		array('xvtrs' => 'none','docid' => Fox\Generator::useAttribute()))));

$grid->fieldcat()->field('export')->noOutput();
$grid->fieldcat()->setGenerators(array(
	'export' => Fox\Generator::url(
		'core',
		'files',
		'download',
		array('docid' => Fox\Generator::useAttribute('id'),
			 'xvtrs' => Fox\Generator::useValue('none'))
	),
	'idele' => Fox\Generator::display('POP_ORD_VALID', Fox\Generator::url(
		'ressource',
		'documents',
		'delete',
		array(
			'docid' => Fox\Generator::useAttribute('docid'),
			'ressource_id' => Fox\Generator::useValue($id)
		)
	)),
	'doctype' => Fox\Generator::useFunction(function($data) {
		return $data->doctype()->description;
	})
));
$blkcv->add($grid);
return $blkcv;